/**
 * fileName:  UdapFactory.java
 * author:  Lei
 * Company:  Cloudland Studio
 * Createdate:  2014-3-1 下午2:34:51
 *
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2020
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2014-3-1          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.udap;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 java.lang.Object#toString(), 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  UdapFactory
 * @author  Lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public abstract class UdapFactory {
	
	private static SqlSession session = null;
	
    static {
    	// 暂时配置为 config_test.xml，由于各自开发数据库配置不同， 不要上传此文件，自己本地维护。
    	ApplicationContext ctx = (ApplicationContext)new ClassPathXmlApplicationContext("config_test.xml");
        SqlSessionFactory sessionFactory = ((SqlSessionFactory )ctx.getBean("sqlSessionFactory"));
        UdapFactory.session = sessionFactory.openSession();
    }
	
	public static <L> L getPersistence(Class<L> clazz) {
		return UdapFactory.session.getMapper(clazz);
	}

}
